<template>
    <div class="table">
            <div class="crumbs">
                <el-breadcrumb separator="/">
                    <el-breadcrumb-item><i class="icon iconfont icon-jifen"></i>项目管理-热门项目设置</el-breadcrumb-item>
                </el-breadcrumb>
            </div>
            <div class="container">
        
                <el-form ref="form" label-width="160px">
                    <el-form-item label="输入项目ID：">
                        <el-input type="number" v-model="id1" placeholder="请输入项目ID" style="width:150px;margin-right:30px;"></el-input>
                        <el-input type="number" v-model="id2" placeholder="请输入项目ID" style="width:150px"></el-input>
                        <p style="color:red;font-size:12px;">* 首页置顶热门项目</p>
                    </el-form-item>
                </el-form>
                <!-- 保存 -->
                <el-button class="save" type="primary" @click="onSubmit">保存</el-button>
                <div style="padding-top:30px;">
                    <p>设置保存之后会展示在首页的热门项目</p>
                    <p><img src="http://appimg.yinsoso.com/remenxiangm.jpg" style="width:375px"/></p>
                </div>
                <div style="width:100%;height:500px;"></div>
            </div>
        </div>
</template>
<script>
export default {
    name:"hotProject",
    data (){
        return{

            id1:'',//项目id
            id2:'',//项目id
        }
    },
    methods:{

        //确认设置
        onSubmit (){
            //console.log(this.selectedOptions[0]);
          
            if(this.id1 =='' || this.id2 ==''){
                this.$notify.info({title: '提示',message: '请输入项目ID'});
                return false;
            }else{
                const param ={
                        itemId1:this.id1,
                        itemId2:this.id2,
                    }
                    this.onSubmitAjax(param);
            }
        },
        //提交到服务器中保存项目
        onSubmitAjax(param){
            const querystring = require('querystring');
            this.$axios.post('/manage/item/hot',querystring.stringify(param)).then(response=>{
                //console.log(response);
                if(response.data.code==200){
                    this.$message({
                        message: '恭喜你，热门项目设置成功',
                        type: 'success'
                    });
                    setTimeout(function(){

                    },1500);

                }else{
                    this.$notify.error({
                        title: '热门项目设置失败',
                        duration:2000,
                        message: '失败原因：'+response.data.msg
                    });
                }

            }).catch(error=>{
                console.log(error);
            });
        }
    }
}
</script>
<style lang="stylus" scoped>
    .save{
        margin-left :160px;
        width :150px;
    }
</style>


